package org.ww;


import sun.misc.Launcher;

import java.net.URL;

/**
 * 测试类加载器实例
 */
public class TestJDKClassLoader {
    public static void main(String[] args) {
        System.out.println(String.class.getClassLoader());
        System.out.println(com.sun.crypto.provider.DESKeyFactory.class.getClassLoader());
        System.out.println(TestJDKClassLoader.class.getClassLoader());
        System.out.println();
        ClassLoader appClassLoader = ClassLoader.getSystemClassLoader();
        ClassLoader extClassLoader = appClassLoader.getParent();
        ClassLoader bootStrapLoader = extClassLoader.getParent();
        System.out.println("the bootstrapLoader : " + bootStrapLoader);
        System.out.println("the extClassloader : " + extClassLoader);
        System.out.println("the appClassLoader : " + appClassLoader);
        System.out.println();
        System.out.println("bootstrapLoader加载以下文件：");
        URL[] urls = Launcher.getBootstrapClassPath().getURLs();
         for (int i = 0; i < urls.length; i++) {
             System.out.println(urls[i]) ;
         }

         System.out.println();
         System.out.println("extClassloader加载以下文件：");
         System.out.println(System.getProperty("java.ext.dirs"));

         System.out.println();
         System.out.println("appClassLoader加载以下文件：");
         System.out.println(System.getProperty("java.class.path"));

    }
}
